package com.java.zhuiyun.api.achievement.controller;

import com.java.zhuiyun.api.achievement.entity.Achievement;
import com.java.zhuiyun.api.achievement.service.AchievementService;
import com.java.zhuiyun.common.response.CommonResult;
import com.java.zhuiyun.util.pageUtil.PageRequest;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

import javax.annotation.Resource;

/**
 * @ClassName AchievementController
 * @Description TODO
 * @Author MJL
 * @Date 2023/9/12 19:17
 **/
@RestController
@RequestMapping("/achievement")
public class AchievementController {
    @Resource
    AchievementService achievementService;
    /**
    * @Author MJL
    * @Description todo 添加成就信息
    * @Date 2023/9/13 9:00
    * @Return  * @param null
    */
    @PostMapping("/addAchievement")
    public CommonResult addAchievement(Achievement achievement, MultipartFile file) {
        return CommonResult.ok(achievementService.addAchievement(achievement,file));
    }
    /**
    * @Author MJL
    * @Description todo 查询所有成就信息
    * @Date 2023/9/13 10:54
    * @Return  * @param null
    */
    @GetMapping("/queryAchievement")
    public CommonResult queryAchievement(Achievement achievement, PageRequest pageRequest) {
        return CommonResult.ok(achievementService.queryAchievement(achievement,pageRequest));
    }
    /**
    * @Author MJL
    * @Description todo 修改成就信息
    * @Date 2023/9/13 11:16
    * @Return  * @param null
    */
    @PutMapping("/updateAchievement")
    public CommonResult updateAchievement(Achievement achievement, MultipartFile file) {
        return CommonResult.ok(achievementService.updateAchievement(achievement,file));
    }
    /**
    * @Author MJL
    * @Description todo 删除单个成就
    * @Date 2023/9/13 14:22
    * @Return  * @param null
    */
    @DeleteMapping("/deleteAchievement")
    public CommonResult deleteAchievement(Integer id) {
        return CommonResult.ok(achievementService.deleteAchievement(id));
    }
    /**
    * @Author MJL
    * @Description todo 将成就下架
    * @Date 2023/9/13 14:32
    * @Return  * @param null
    */
    @PostMapping("/bannedAchievement")
    public CommonResult bannedAchievement(Integer id) {
        return CommonResult.ok(achievementService.bannedAchievement(id));
    }
    /**
    * @Author MJL
    * @Description todo 将成就上架
    * @Date 2023/9/13 14:39
    * @Return  * @param null
    */
    @PostMapping("/enableAchievement")
    public CommonResult enableAchievement (Integer id) {
        return CommonResult.ok(achievementService.enableAchievement(id));
    }

//    /*
//    * @Author WX
//    * @Description 查询可用成就信息
//    * @Date 2023/10/16 8:52
//    * @Return
//    * @param null
//    */
//    @GetMapping("/selectAvailableAchievement")
//    public CommonResult selectAvailableAchievement () {
//        return CommonResult.ok(achievementService.selectAvailableAchievement());
//    }
}
